R for Lunch

Reproducible workflows

John Little

Center for Data & Visualization Sciences

Duke University Libraries

2024-02-19

Today’s topics



You should have the latest version of Quarto!!

Reproducibility

Streaming previous workshops

R for Lunch: a lunchtime learning series


See Also: Online Resources: (Rfun | CDVS resources)

Housekeeping

  • Drew / Lauren / breakout rooms
  • CDVS
    • Themes
      • Data Management (Plans, Reproducibility, Repositories)

      • Data Science

      • Data Visualization

      • GIS and Spatial Analysis

      • Data Sources

Housekeeping continued

Ideal: R as a practical reproducible workflow

Projects

New Project > Quarto Project

  • Do use code notebooks

  • Do use relative file paths and {here}

  • Do use Restart R and Run All Chunks

  • Do not rewrite code for different computers

  • Do not use setwd()

  • Do not use rm(list=ls())

Reproducibility settings for your IDE

Global options > Code ^^
<- Global options > General

Citation management

Use a bibliography manager such as Zotero

Then,

RStudio > Quarto Notebook > Insert > Citation

Example DOI: 10.18637/jss.v059.i10

Publish

  • Full Instructions

  • Steps (simplified)

    1. In CLI (terminal, powershell, bash, etc.): quarto publish (For select Quarto project types)

    2. Choose a destination (e.g. quarto.pub or netlify.com)

Manuscript demo


Instructions simplified

  1. In CLI (e.g. RStudio Terminal, PowerShell, Bash, etc.):
    quarto create > project > manuscript
    • Identify LFS path / location
  2. Go to that location; double-click <new_proj_name>.Rproj file (if using R)
  3. usethis::use_git()
  4. in _quarto.yml: change jats: default to pdf: default

{renv}


Create reproducible environments for your R projects by storing the exact versions of the code interpreter and r packages within the version-control repo


  • Get Started
    • renv::init()
    • renv::snapshot()
    • and renv::restore()

Binder (Containers)


The Binder project makes it easy to share live compute environments. This is documented very well at Quarto.

In essence:

  • CLI terminal: quarto use binder

We are here to help

  • askData@duke.edu

  • https://library.duke.edu/data

  • https://is.gd/littleconsult

Closing

Where to find

Bye for now